/**
 * 
 */
package com.cplsystems.incidencias.vm.utils;

import java.util.List;

import org.zkoss.bind.annotation.BindingParam;
import org.zkoss.bind.annotation.GlobalCommand;
import org.zkoss.bind.annotation.Init;
import org.zkoss.bind.annotation.NotifyChange;
import org.zkoss.zk.ui.select.annotation.VariableResolver;

import com.cplsystems.incidencias.business.DatosGenerales;
import com.cplsystems.incidencias.business.Transaccion;
import com.cplsystems.incidencias.vm.utils.variables.TransactionsVariables;

/**
 * @author César Palalía López (csr.plz@aisa-automation.com)
 * 
 */
@VariableResolver(org.zkoss.zkplus.spring.DelegatingVariableResolver.class)
public class TransactionsVM extends TransactionsVariables {

	private static final long serialVersionUID = 5278332995507089738L;

	@Init
	public void init() {
		super.init();
	}

	@NotifyChange("transaciones")
	@GlobalCommand
	public void transactionsByFirma(
			@BindingParam("transaciones") List<Transaccion> transaciones) {
		this.transaciones = transaciones;
		for (Transaccion trans : transaciones) {
			DatosGenerales datosGenerales = datosGeneralesService
					.getDatosGeneralesByPersona(trans.getEmpleado());
			trans.getEmpleado().setNombreCompleto(
					datosGenerales.getNombreCompleto());
		}
	}

}
